<template>
  <div>
    <el-card style="margin-bottom: 10px">
        <div v-if="!flag">
          <span>选择考评：</span>
          <el-select v-model="templateValue" placeholder="选择考评" style="margin-right: 5px">
            <el-option
                v-for="item in templateOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value">
            </el-option>
          </el-select>
        </div>
        <div v-if="flag"><span>没有正在进行的考评</span></div>
    </el-card>

    <el-card>
      <el-collapse v-for="item in tableData">
        <el-collapse-item :title="item.content">
          <el-collapse v-for="items in item.child">
            <el-collapse-item :title="items.content" style="margin-left: 30px">
              <el-collapse v-for="content in items.child" style="margin-left: 30px">
                <el-collapse-item :title="content.content">
                  <div><span>自评：{{ content.score }}</span></div>
                  <div><span>评估组：{{ content.expertScore }}</span></div>
                </el-collapse-item>
              </el-collapse>
            </el-collapse-item>
          </el-collapse>
        </el-collapse-item>
      </el-collapse>
    </el-card>
  </div>
</template>

<script>
import request from "@/urils/request";

export default {
  name: "GetScore",
  data() {
    return {
      tableData: [],
      templateOptions: [],
      templateValue: null,
      schoolOptions: [],
      schoolValue: null,

      flag: false,
      schoolFlag: false,
      fileList: [],
      records: {
        criterionId: '',
        schoolId: '',
        score: ''
      }
    }
  },
  methods: {
    loadTemplate() {
      request.get('/evaluation/getList').then(res => {
        if (res.code === '200') {
          if (res.data.length === 0) {
            this.flag = true
          } else {
            this.flag = false
            for (let i in res.data) {
              this.templateOptions.push({
                value: res.data[i].templateId,
                label: res.data[i].name
              })
            }
          }
        }
      })
    },
    getData(value) {
      request.get('/criterion/selectAllScore', {
        params: {
          id: value,
          userId: JSON.parse(localStorage.getItem("user")).id
        }
      }).then(res => {
        if (res.code === '200') {
          this.tableData = res.data
        } else {
          console.log(res.msg)
          this.$message.error(res.msg)
        }
      })
    },
  },
  created() {
    this.loadTemplate()
  },
  watch: {
    templateValue: function (newVal, oldVal) {
      this.getData(newVal)
    }
  }
}
</script>

<style scoped>

</style>